Skip to contentMethod: CommentState(Scanner, Integer, Integer)
      1: package scanner;
2: 
3: import model.Position;
4: import symbols.AbstractSymbol;
5: import symbols.CommentSymbol;
6: import basic.Buffer;
7: 
8: /**
9:  * This class represents the commentState.
10:  * 
11:  * @author HFW410
12:  * 
13:  */
14: public class CommentState extends AbstractState {
15:         /**
16:          * represents the collected Commentsymbols.
17:          */
18:         private String collectedComment;
19: 
20:         /**
21:          * This is the constructor for a new CommentState.
22:          * 
23:          * @param myScanner
24:          *            is the used Scanner.
25:          * @param beginningColumn
26:          *            is the Begin Column of the symbol
27:          * @param beginningRow
28:          *            is the begin row of the symbol
29:          */
30:         public CommentState(final Scanner myScanner, final Integer beginningColumn,
31:                         final Integer beginningRow) {
32:                 super(myScanner, beginningColumn, beginningRow);
33:                 this.collectedComment = ScannerConstants.EMPTYSTRING;
34:         }
35: 
36:         @Override
37:         public AbstractState action(final Character character,
38:                         final Buffer<AbstractSymbol> currentResult, final String dataPath)
39:                         throws InterruptedException {
40:                 if (character.equals(ScannerConstants.NEWLINE)) {
41:                         this.finish(currentResult, dataPath);
42:                         return this.getMyScanner().getSelectionState();
43:                 } else {
44:                         this.collectedComment = this.collectedComment + character;
45:                         this.getMyScanner().skip();
46:                         return this;
47:                 }
48:         }
49: 
50:         @Override
51:         protected void finish(final Buffer<AbstractSymbol> currentResult, final String dataPath)
52:                         throws InterruptedException {
53:                 currentResult.put(new CommentSymbol(this.collectedComment, new Position(this
54:                                 .getBeginningRow(), this.getBeginningColumn(), dataPath)));
55: 
56:         }
57: }